/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "HIST_TIP_PERS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HistTipPers.findAll", query = "SELECT h FROM HistTipPers h"),
    @NamedQuery(name = "HistTipPers.findByTPerCod", query = "SELECT h FROM HistTipPers h WHERE h.histTipPersPK.tPerCod = :tPerCod"),
    @NamedQuery(name = "HistTipPers.findByPerCod", query = "SELECT h FROM HistTipPers h WHERE h.histTipPersPK.perCod = :perCod"),
    @NamedQuery(name = "HistTipPers.findByHisFech", query = "SELECT h FROM HistTipPers h WHERE h.hisFech = :hisFech"),
    @NamedQuery(name = "HistTipPers.findByHisEst", query = "SELECT h FROM HistTipPers h WHERE h.hisEst = :hisEst")})
public class HistTipPers implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected HistTipPersPK histTipPersPK;
    @Column(name = "HIS_FECH")
    @Temporal(TemporalType.DATE)
    private Date hisFech;
    @Column(name = "HIS_EST")
    private Short hisEst;
    @JoinColumn(name = "T_PER_COD", referencedColumnName = "T_PER_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoPersonal tipoPersonal;
    @JoinColumn(name = "PER_COD", referencedColumnName = "PER_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Personal personal;

    public HistTipPers() {
    }

    public HistTipPers(HistTipPersPK histTipPersPK) {
        this.histTipPersPK = histTipPersPK;
    }

    public HistTipPers(short tPerCod, int perCod) {
        this.histTipPersPK = new HistTipPersPK(tPerCod, perCod);
    }

    public HistTipPersPK getHistTipPersPK() {
        return histTipPersPK;
    }

    public void setHistTipPersPK(HistTipPersPK histTipPersPK) {
        this.histTipPersPK = histTipPersPK;
    }

    public Date getHisFech() {
        return hisFech;
    }

    public void setHisFech(Date hisFech) {
        this.hisFech = hisFech;
    }

    public Short getHisEst() {
        return hisEst;
    }

    public void setHisEst(Short hisEst) {
        this.hisEst = hisEst;
    }

    public TipoPersonal getTipoPersonal() {
        return tipoPersonal;
    }

    public void setTipoPersonal(TipoPersonal tipoPersonal) {
        this.tipoPersonal = tipoPersonal;
    }

    public Personal getPersonal() {
        return personal;
    }

    public void setPersonal(Personal personal) {
        this.personal = personal;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (histTipPersPK != null ? histTipPersPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HistTipPers)) {
            return false;
        }
        HistTipPers other = (HistTipPers) object;
        if ((this.histTipPersPK == null && other.histTipPersPK != null) || (this.histTipPersPK != null && !this.histTipPersPK.equals(other.histTipPersPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.HistTipPers[ histTipPersPK=" + histTipPersPK + " ]";
    }
    
}
